<?php $orgAccount = $this->Session->read('org_account'); ?>

<!-- nav -->
<nav class="nav-primary hidden-xs">
    <ul class="nav">
        <li class="<?php echo ($this->params['controller'] == 'organisation' && $this->params['action'] == 'index' ) ? 'active' : ''; ?>">
            <a href="<?php echo $this->Html->url("/" . $orgAccount['Organisation']['slug']); ?>">
                <i class="fa fa-dashboard"></i>
                <span>Dashboard</span>
            </a>
        </li>
        <!--<li class="dropdown-submenu <?php echo ($this->params['controller'] == 'organisation' && in_array($this->params['action'], array('members', 'groups', 'images')) ) ? 'active' : ''; ?>">
            <a href="<?php echo $this->Html->url('/' . $orgAccount['Organisation']['slug'] . '/members'); ?>">
                <i class="fa fa-group"></i>
                <span>Members</span>
            </a>

            <ul class="dropdown-menu">                
                <li>
                    <a href="<?php echo $this->Html->url('/' . $orgAccount['Organisation']['slug'] . '/members'); ?>">&nbsp;<i class="fa fa-user"></i> Profiles</a>                    
                </li>
                <?php if (false) { ?>
                    <li>
                        <a href="<?php echo $this->Html->url('/' . $orgAccount['Organisation']['slug'] . '/groups'); ?>"><i class="fa fa-group"></i> Groups</a>              
                    </li>
                <?php } ?>
                <li>
                    <a href="<?php echo $this->Html->url('/' . $orgAccount['Organisation']['slug'] . '/images'); ?>"><i class="fa fa-picture-o"></i> Photos</a>              
                </li>
            </ul>
        </li>-->

        <?php
        foreach ($orgAccount['Organisation']['Module'] as $module) {
            if ($module['add_to_menu'] == 1) {
                ?>
                <li class="dropdown-submenu <?php echo ($this->params['controller'] == $module['controller'] && $this->params['action'] == $module['action'] ) ? 'active' : ''; ?>">
                    <a href="<?php echo $this->Html->url('/' . $orgAccount['Organisation']['slug'] . '/' . $module['controller'] . "/" . $module['action']); ?>" >
                        <i class="fa <?php echo $module['icon']; ?>"></i>
                        <span><?php echo $module['name']; ?></span>
                    </a>

                    <?php
                    if (isset($module['ModuleMenu'][0])) {
                        echo "<ul class='dropdown-menu'>";
                        foreach ($module['ModuleMenu'] as $menu) {
                            ?>
                        <li>
                            <a href="<?php echo $this->Html->url('/' . $orgAccount['Organisation']['slug'] . '/' . $menu['controller'] . "/" . $menu['action']); ?>" >
                                <i class="fa <?php echo $menu['icon']; ?>"></i>
                                <span><?php echo $menu['display_name']; ?></span>
                            </a>
                        </li><?php
                    }
                    echo "</ul>";
                }
                ?>
                </li>
            <?php
            }
        }
        ?>

    </ul>
</nav>
<!-- / nav -->